package com.aliyun.oss.mapper;

import com.aliyun.oss.pojo.ArticleCategory;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ArticleCategoryMapper {
    @Select("SELECT  article_category.id,article_category.user_id,article_category.cate_name,article_category.`cate-alias` cateAlias FROM user LEFT JOIN article_category ON `user`.id=article_category.user_id WHERE user.id=#{id}")
    List<ArticleCategory> selectAllArticleCategory(Integer id);

    @Insert("INSERT INTO article_category (user_id, cate_name, `cate-alias`) VALUES (#{id}, #{articleCategory.cateName}, #{articleCategory.cateAlias});")
    void addArticleCategory(@Param("id") Integer id, @Param("articleCategory") ArticleCategory articleCategory);

    @Update("UPDATE article_category SET cate_name = #{articleCategory.cateName},`cate-alias` = #{articleCategory.cateAlias} WHERE id = #{articleCategory.id} and user_id=#{id}; ")
    void updateArticleCategory(@Param("id") Integer id, @Param("articleCategory") ArticleCategory articleCategory);
    @Delete("DELETE FROM article_category WHERE id = #{id} AND user_id = #{userId};")
    void deleteArticleCategory(Integer userId, String id);
}
